Mathematical compression algorithms fall into two categories: lossy (which loses image quality) and lossless (which retains the original image quality).
The theory behind compression is that the human eye is not sensitive enough to notice minimal amounts of loss in detail and color. Lossy compression creates smaller files than lossless by discarding some portions of the original image information, thereby slightly degrading image quality. Lossless compression never discards any information about the original file. instead it save space by omitting unused colors from the palette or by reducing repetitive data patterns.
The three file formats most often used to compress images for display on the Web are GIF, JPEG, and PNG.
The Graphics Interchange Format (GIF) saves images using a lossless compression called LZW. However, GIFs only support up to 256 colors (also known as 8-bit color). This makes GIF a poor format for saving photos, which look better in True Color (which permits millions of colors).
Another lossless compression format is the Portable Network Graphic (PNG). However, unlike GIF, the PNG format supports True Color. You can safely save your color photograph as a PNG, achieving compression without losing data. A photo saved as a PNG file will usually be 15 to 20% smaller in size than the same photo saved as a GIF.
JPEG is the most commonly used format for saving photos, and it achieves significant compression as the cost of some data loss. The degree of compression can usually be specified in the camera, and again in the photo editing software (such as FotoFinish). A Fine setting will compress the least and preserve the most image information. A Compact or Coarse setting will create a small file size but will lose more image data. Compact compression may also create JPEG artifacts, which are minor distortions in the image.
Note: Saving a JPEG repeatedly during a single editing session will not degrade image quality because during the session the image remains loaded uncompressed in memory. You will also not lose any quality if you open and save your image without making any changes. The JPEG file will only lose quality if it's been opened, edited, saved, and then closed.
Changing the quality setting of a JPEG file that was initially saved using the Compact setting to a Fine setting will not restore it to the original image quality. Once image information is lost it cannot be recovered.